package io.renren.modules.workjobs.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.workjobs.entity.UserPositionEntity;
import io.renren.modules.workjobs.service.UserPositionService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author nyc
 * @email 2691778746@qq.com
 * @date 2022-03-12 14:33:03
 */
@RestController
@RequestMapping("workjobs/userposition")
public class UserPositionController {
    @Autowired
    private UserPositionService userPositionService;


    /**
     * 查询我所审核的职位
     */
    @RequestMapping("/list-publish")
    public R iPageListPosition(@RequestParam Map<String, Object> params){

        PageUtils page = userPositionService.iPageListPosition(params);
        return R.ok().put("page", page);
    }

    /**
     * 查询我所发布的职位信息
     */
    @RequestMapping("/list-publish-s")
    public R iPageListPositionPublish(@RequestParam Map<String, Object> params){
        PageUtils page = userPositionService.iPageListPositionPublish(params);
        return R.ok().put("page", page);
    }




    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("workjobs:userposition:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userPositionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("workjobs:userposition:info")
    public R info(@PathVariable("id") Long id){
		UserPositionEntity userPosition = userPositionService.getById(id);

        return R.ok().put("userPosition", userPosition);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("workjobs:userposition:save")
    public R save(@RequestBody UserPositionEntity userPosition){
		userPositionService.save(userPosition);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("workjobs:userposition:update")
    public R update(@RequestBody UserPositionEntity userPosition){
		userPositionService.updateById(userPosition);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("workjobs:userposition:delete")
    public R delete(@RequestBody Long[] ids){
		userPositionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
